]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
userWidget: Simplify icon size setting a bit
authorJonas Dreßler <verdre@v0yd.nl>
Sun, 16 Feb 2020 22:03:14 +0000 (23:03 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Tue, 18 Feb 2020 22:10:00 +0000 (22:10 +0000)
Remove the default icon size of -1 and always set the container StBin to
a real size. This fixes an error where the "width" and "height"
properties get set to -2 (which is -1 * scaleFactor) in the `_init`
function.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1018

js/ui/userWidget.js

index e5f7883381e8ca83aa267fec2513743433035f04..d749ceebe2ad7a390d76d0309472cb3f4493d914 100644 (file)
@@ -7,7 +7,6 @@ const { Clutter, GLib, GObject, St } = imports.gi;
 
 const Params = imports.misc.params;
 
-const UNKNOWN_AVATAR_ICON_SIZE = -1;
 var AVATAR_ICON_SIZE = 64;
 
 // Adapted from gdm/gui/user-switch-applet/applet.c
@@ -22,7 +21,7 @@ class Avatar extends St.Bin {
         params = Params.parse(params, {
             styleClass: 'user-icon',
             reactive: false,
-            iconSize: UNKNOWN_AVATAR_ICON_SIZE,
+            iconSize: AVATAR_ICON_SIZE,
         });
 
         super._init({
@@ -72,20 +71,11 @@ class Avatar extends St.Bin {
         }
     }
 
-    _getIconSize() {
-        if (this._iconSize !== UNKNOWN_AVATAR_ICON_SIZE)
-            return this._iconSize;
-        else
-            return AVATAR_ICON_SIZE;
-    }
-
     setSensitive(sensitive) {
         this.reactive = sensitive;
     }
 
     update() {
-        let iconSize = this._getIconSize();
-
         let iconFile = null;
         if (this._user) {
             iconFile = this._user.get_icon_file();
@@ -98,8 +88,8 @@ class Avatar extends St.Bin {
 
             let { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
             this.set_size(
-                iconSize * scaleFactor,
-                iconSize * scaleFactor);
+                this._iconSize * scaleFactor,
+                this._iconSize * scaleFactor);
             this.style = `
                 background-image: url("${iconFile}");
                 background-size: cover;`;
@@ -107,7 +97,7 @@ class Avatar extends St.Bin {
             this.style = null;
             this.child = new St.Icon({
                 icon_name: 'avatar-default-symbolic',
-                icon_size: iconSize,
+                icon_size: this._iconSize,
             });
         }
     }